﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace NHI.Sync.Tools.Forms
{
    /// <summary>
    /// Window_RunResult.xaml 的交互逻辑
    /// </summary>
    public partial class Window_RunResult : Window
    {
        //public Window_RunResult()
        //{
        //    InitializeComponent();
        //}

        public Window_RunResult(List<string> files)
        {
            InitializeComponent();
            _Files = files;
        }

        List<string> _Files = null;

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < _Files.Count; i++)
            {
                string f = _Files[i];
                string n = System.IO.Path.GetFileName(f);
                var t = new TabItem();
                tabs.Items.Add(t);
                if (n.Length > 8)
                    n = string.Concat(n.Substring(0, 5), "...");
                t.Header = n;
                var g = new Grid();
                t.Content = g;

                var t1 = new TextBox();
                g.Children.Add(t1);

                t1.Text = System.IO.File.ReadAllText(f);
                t1.TextWrapping = TextWrapping.Wrap;
                t1.AcceptsReturn = true;
                t1.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
                t1.IsReadOnly = true;
                t1.Height = 400;
            }
            tabs.SelectedIndex = 0;
        }
    }
}
